package com.mc.moring.widge;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.mc.moring.R;

public class LoadingDialog extends AlertDialog{

    private ImageView animImage;
    private Animation animation;

    public LoadingDialog(Context context) {
        super(context, R.style.LoadDialogStyle);
        setCanceledOnTouchOutside(false);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        animImage = findViewById(R.id.iv_anim);
        showAnim();
    }
    @Override
    public void show() {
        super.show();
    }

    @Override
    public void dismiss() {
        super.dismiss();
    }

    private void showAnim(){
        animation = new RotateAnimation(
                0f,
                360f,
                Animation.RELATIVE_TO_SELF,
                0.5f,
                Animation.RELATIVE_TO_SELF,
                0.5f
        );
        animation.setDuration(1000);
        animation.setRepeatCount(1000);
        animation.setFillAfter(true);
        animImage.startAnimation(animation);
    }
}
